# Contributor: Mark Riedesel <mark@klowner.com>
# Maintainer: Leon Marz <main@lmarz.org>
pkgname=opencolorio
pkgver=2.4.0
pkgrel=0
pkgdesc="Color management framework for visual effects and animation"
url="https://opencolorio.org/"
arch="all"
license="BSD-3-Clause AND GPL-2.0-or-later"
# Please do not include openimageio.
# It creates a circular dependency.
makedepends="cmake
	expat-dev
	freeglut-dev
	glew-dev
	lcms2-dev
	minizip-ng-dev
	openexr-dev
	py3-pybind11-dev
	pystring-dev
	python3-dev
	samurai
	yaml-cpp-dev
	"
subpackages="py3-$pkgname:py3 $pkgname-dev $pkgname-tools"
source="$pkgname-$pkgver.tar.gz::https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v$pkgver.tar.gz"
builddir="$srcdir/OpenColorIO-$pkgver"

case $CARCH in
	riscv64) options="$options !check" ;;
	*) ;;
esac

prepare() {
	default_prepare
	find . -name CMakeLists.txt -exec sed -i -e "s/OpenGL::OpenGL/OpenGL::GL/" {} +
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DOCIO_BUILD_TESTS=OFF \
		-DOCIO_BUILD_GPU_TESTS=OFF \
		-DOCIO_INSTALL_EXT_PACKAGES=NONE
	cmake --build build
}

check() {
	ninja -C build test
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

tools() {
	pkgdesc="OpenColorIO color management framework tools"

	amove usr/bin
}

py3() {
	pkgdesc="Python3 bindings for OpenColorIO color management framework"

	amove usr/lib/python*
}

sha512sums="
11ad89b3ac30700be58181a0bdd4154a3ae2bf59651edb48629c51c7f1fadf221394abb285efd9b6c259195821a4e531043b266eea36d8fa4382f23c3b54ab6d  opencolorio-2.4.0.tar.gz
"
